package com.lagou.initializer;

import com.lagou.application.ContextUtils;
import org.springframework.web.WebApplicationInitializer;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

public class MyWebApplicationInitializer extends ContextUtils implements WebApplicationInitializer {
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        // 将DispatcherServlet添加到tomcat上下文中去
        ServletRegistration.Dynamic registration = servletContext.addServlet("app", super.getDispatcherServlet());
        if (registration != null) {
            registration.setLoadOnStartup(1);
            registration.addMapping("/app/*");
        }
    }

}
